package leetcode.code0967;

import java.util.ArrayList;
import java.util.List;

import leetcode.IDebug;

public class Solution implements IDebug {

	List<Integer> ans;

	int n, k;

	public int[] numsSameConsecDiff(int n, int k) {
		ans = new ArrayList<>();
		this.n = n;
		this.k = k;
		for (int i = 1; i < 10; i++) {
			this.find(i, 1, i);
		}
		int[] ret = new int[ans.size()];
		int p = 0;
		for (Integer num : ans) {
			ret[p++] = num;
		}
		return ret;
	}

	private void find(int num, int index, int total) {
		if (index == n) {
			ans.add(total);
			return;
		}
		if (num + k < 10) {
			this.find(num + k, index + 1, total * 10 + num + k);
		}
		if (k != 0 && num - k > -1) {
			this.find(num - k, index + 1, total * 10 + num - k);
		}
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub
		this.numsSameConsecDiff(2, 1);
	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
